<?PHP
App::uses('CakeEmail', 'Network/Email');

class ContactsController extends AppController {

    var $components = array('Email');

    function send() {
        if(!empty($this->data)) {
            $this->Contact->set($this->data);

            if($this->Contact->validates()) {
				
				CakeEmail::deliver('info@pokerface.de', 'Website request', 'Von ' . $this->data['Contact']['name'] . '\n\n' . $this->data['Contact']['message'], array('from' => $this->data['Contact']['email']));

                $this->Session->setFlash(__('Ihre Nachricht wurde versendet.'));
                // Display the success.ctp page instead of the form again
                $this->render('success');
            } else {
                $this->render('index');
            }
        }
    }

    function index() {
        // Placeholder for index. No actual action here, everything is submitted to the send function.
    }

}
